/*
 * Sound.h
 *
 *  Created on: 2009/01/31
 *      Author: Yongshik Cho
 */

#ifndef SOUND_H_
#define SOUND_H_

#include <deque>
#include "core/Prerequisites.h"
#include "core/ISmartPtr.h"
#include "sqplus/sqplus.h"
using namespace SqPlus;


class Sound : public ISmartPtr<Sound>
{
public:
	static const uint32 CHANNEL_TYPE_MONO8 		= 0x1100;
	static const uint32 CHANNEL_TYPE_MONO16 	= 0x1101;
	static const uint32 CHANNEL_TYPE_STEREO8 	= 0x1102;
	static const uint32 CHANNEL_TYPE_STEREO16 	= 0x1103;

public:
	Sound(const String& p, const uint32 id, const uint32 format, const int32 rate, void* stream);
	virtual ~Sound();

public:
	inline const uint32 getId() const { return mId; }
	inline const String& getPath() const { return mPath; }
	inline const void* getStream() const { return mStream; }
	inline const uint32 getFormat() const { return mFormat; }
	inline const int32 getRate() const { return mRate; }

	inline const uint32 getQueueCount() const { return (uint32)mQueue.size(); }
	inline void pushBuffer(const uint32 id) { mQueue.push_front(id); }
	inline const uint32 popBuffer()
	{
		if(!mQueue.size())
			return 0;

		uint32 id = *(mQueue.rbegin());
		mQueue.pop_back();

		return id;
	}

private:
	String	mPath;
	uint32	mId;
	uint32	mFormat;
	void*	mStream;
	int32	mRate;

	deque<uint32>	mQueue;
};

//must be declared here
DECLARE_INSTANCE_TYPE(Sound)

#endif /* SOUND_H_ */
